# 作者: 家里蹲 吴越洋
# 2023年02月25日08时39分44秒
class House_Item:
    """家具"""
    def __init__(self, name, area):
        self.name = name
        self.area = area



bed = House_Item("席梦思", 4)
table = House_Item("餐桌", 1.5)
chest = House_Item("衣柜", 2)


class House:
    def __init__(self, type, area):
        self.type = type
        self.area = area
        self.free_area = area
        self.item_list = []

    def __str__(self):
        return "户型：%s\n总面积：%s\n剩余面积：%s\n已有的家具是%s" % (self.type, self.area, self.free_area, self.item_list)

    def add_item(self, item: House_Item):
        if self.free_area > item.area:
            print("添加了占地%s的家具%s" % (item.area, item.name))
            self.free_area -= item.area
            self.item_list.append(item.name)
        else:
            print("已经无法添加家具")

    def __del__(self):
        #销毁对象
        return


if __name__ == "__main__":
    print(bed)  # 没加__str__无法打印出结果
    zhuzhai = House("三室一厅", 80)
    print(zhuzhai)
    zhuzhai.add_item(bed)
    zhuzhai.add_item(table)
    zhuzhai.add_item(chest)
    print(zhuzhai)
    del zhuzhai
    print('-'*50)